/* $Header: zone_config.h,v 2.6 05/03/02 11:36:08 przybyls Exp $ */

/***********************************************************************/
/* INCLUDE FILE NAME: zone_config.h                                    */
/* ==================                                                  */
/*                                                                     */
/* Author:              Lesley Freed                                   */
/*                                                                     */
/* COMMENT:  This is an include file which defines all of the          */
/*           configuration constants and variables for the zones.      */
/*                                                                     */
/***********************************************************************/

#ifndef Z_CONFIG_H
#define Z_CONFIG_H


/*****************************/
/*   SYMBOLIC CONSTANTS      */
/*****************************/

#define TEMP_OFFSET     273     /* 273 deg C offset in temp values     */

#define LIMIT_OFFSET    25      /* 25 deg C offset in temp values      */
                                /* before a thermal fault condition    */


#define OVEN_MAX  256*64*(450+TEMP_OFFSET+LIMIT_OFFSET) /* initial max. setpt */

/* Power sharing constants */

#define ELECTRONICS_WATTAGE 230 /* worst case electronics power consumption */
#define FAST_GC_WATTAGE     2990 /* max. total wattage for a GC with fast oven */
#define REG_GC_WATTAGE      2300 /* max. total wattage for a GC with reg oven  */

#define REG_OVEN_WATTAGE    1600 /* nominal regular oven wattage             */
#define FAST_OVEN_WATTAGE   2250 /* nominal fast oven wattage                */

#define OVEN_WATTS                                                             \
 (Oven_Table.config->zone_type==(BIT8)FAST_OVEN)?FAST_OVEN_WATTAGE:            \
                                                 REG_OVEN_WATTAGE

/* max. total small zone power for a GC with a fast ramping oven */
#define FAST_THERMAL_WATTAGE (FAST_GC_WATTAGE-ELECTRONICS_WATTAGE)

/* max. total small zone power for a GC with a regular ramping oven */
#define REG_THERMAL_WATTAGE  (REG_GC_WATTAGE-ELECTRONICS_WATTAGE)

#define M70 15283  /* Slope of wattage = mx + b calculation       */
#define B70 54     /* y-intercept of wattage = mx + b calculation */
#define R70 2217   /* lowest 70W heater resistance in .01 ohms    */
#define M150 14963 /* Slope of wattage = mx + b calculation       */
#define B150 54    /* y-intercept of wattage = mx + b calculation */
#define R150 1035  /* lowest 150W heater resistance in .01 ohms   */

/* Wattage sense constants */
#define MAX_TOT_WATTS   220              /* Max allowable wattage per zone  */
                                         /* trio: either inja,deta,auxa or  */
                                         /* injb,detb,auxb                  */

#define OVER_CURRENT_WATTS MAX_TOT_WATTS+1 /* Wattage for over current sense */
#define OVER_150_WATTS     MAX_TOT_WATTS+1 /* Wattage for >150 watt sense:   */
                                           /* out of range                   */

/* COC ramp compensation control constants */
#define   PCOC_RAMP_MULT    11     /* effective 1.1X gain */
#define   PCOC_RAMP_DIV     10000

#define   PCOC_DEAD_TIME    4000   /* 4 second dead time in milliseconds            */
#define   PCOC_DEAD_TIME2   67     /* 4 second dead time in 1000ths of a minute     */
#define   PCOC_BRAKE_TIME   67     /* 4 second anticipatory time before a ramp ends */
                                   /* in 1000ths of a minute                        */

/* ACI ramp compensation control constants */
#define   ACI_RAMP_MULT     75     /* effective 7.5X gain */
#define   ACI_RAMP_DIV      10000

#define   ACI_DEAD_TIME     7000   /* 7 second dead time in milliseconds            */
#define   ACI_DEAD_TIME2    118    /* 7 second dead time in 1000ths of a minute     */
#define   ACI_BRAKE_TIME    118    /* 7 second anticipatory time before a ramp ends */
                                   /* in 1000ths of a minute                        */

/* Filter constants */

/* Setpoint filter constants */
#define OVEN_FILT_SHIFT       7
#define OVEN_FILT_MASK        0x0000007f
#define SMALL_ZONE_FILT_SHIFT 6
#define SMALL_ZONE_FILT_MASK  0x0000003f
#define PCOC_FILT_SHIFT       6
#define PCOC_FILT_MASK        0x0000003f

/* RTD adc reading filter constants */

#define OVEN_BOXCAR_SIZE         0
#define BOXCAR_4_PT_SIZE         4
#define BOXCAR_2_PT_SIZE         2

/* Rate limits */

#define MIN_ZONE_RATE           0
#define MAX_VERY_FAST_RATE  72000         /* 720.00 deg C/ minute */
#define MAX_FAST_RATE       12000         /* 120.00 deg C/ minute */
#define MAX_OVEN_RATE       12000         /* 120.00 deg C/ minute */
#define MAX_PCOC_RATE       35000         /* 350.00 deg C/ minute */
#define MAX_AUX_RATE        65000         /* 650.00 deg C/ minute */
#define MAX_ZONE_RATE        7500          /* 75.00 deg C/ minute  */
#define MAX_ACI_RATE  MAX_PCOC_RATE  /* REVISIT: 100.00 deg C/ minute */

/* Minimum and maximum temperatures */

#define MIN_OVEN_MAX    70         /* min allowable temp setpt for oven max   */

#define MAX_OVEN_CALIB   10*100    /* max delta for oven calibration          */
#define MIN_OVEN_CALIB  -10*100    /* min delta for oven calibration          */
#define MAX_CALIB_TEMP  460*100    /* max measured temp for calibration       */
#define MIN_CALIB_TEMP  -90*100    /* min measured temp for calibration       */

/* Limits used to determine whether or not a sensor is shorted */

        /* min value considered due to cryo (LN2)  */
#define MIN_POSSIBLE_LN2_TEMP (-220+TEMP_OFFSET)*64*256

        /* min value considered due to cryo (LCO2) */
#define MIN_POSSIBLE_LCO2_TEMP (-80+TEMP_OFFSET)*64*256

        /* min value without cryo                  */
#define MIN_POSSIBLE_TEMP      (-80+TEMP_OFFSET)*64*256

/* min allowable temp actual for small zone.  NOTE:  the cryo blast option on */
/* the COC inlet with LN2 and the inlet temp off can cause the inlet to get   */
/* very cool (e.g. -90 C with oven temp of -30)                               */
#define MIN_ZONE_TEMP_ACTUAL MIN_POSSIBLE_LN2_TEMP

/* PID integral accummulator clamp as a percent of full power: +/- 512 max    */

typedef enum
{
   FP_200_PERCENT    = 0,
   FP_100_PERCENT    = 1,
   FP_50_PERCENT     = 2,
   FP_25_PERCENT     = 3,
   END_OF_FP_PERCENT = 4   /* Warning: keep at end, marks last FP option */

} INTEG_CLAMP;

typedef enum
{
   FREQ_512     = 0,   /* 5.12 Hz */
   FREQ_2560    = 1,   /* 25.6 Hz */
   FREQ_51200   = 2    /* 51.2 Hz */

} CONTROL_FREQ;

typedef enum
{
   RTD    = 0,          /* standard prt lookup                              */
   TC     = 1,          /* amplified thermocouple voltage lookup            */
   MAX_SENSOR_TYPE      /* flag for end of sensor type                      */

} TEMP_SENSOR;

/* Zone type PID constants, control rates */

typedef enum
{
   SLOW_CONTROL      = 0,
   OVEN_CONTROL      = 1,
   PCOC_CONTROL      = 2, /* 25.6 Hz: special scaling        */
   CIS4_CONTROL      = 3, /* 25.6 Hz: gerstel PTV            */
   CRYO_TRAP_CONTROL = 4, /* 25.6 Hz: cryo focus             */
   FPD_BLOCK_CONTROL = 5, /* SLOW CONTROL with a slave zone  */
   FPD_XFR_CONTROL   = 6  /* SLOW CONTROL with a master zone */

} ZONE_CONTROL;

typedef enum
{
   NO_RAMP_COMP  = 0,
   COC_RAMP_COMP = 1,
   ACI_RAMP_COMP = 2

} RAMP_COMP;

#define MAX_ZONE_RAMP_COMP_TYPE ACI_RAMP_COMP

/***************************/
/* Detector zone constants */
/***************************/

#define FID_PROP_K   21             /* 5.12 Hz control       */
#define FID_INTEG_K  16             /* Last changed: 11/2/95 */
#define FID_DERIV_K  54
#define FID_CONTROL  SLOW_CONTROL   /* slow control rate */
#define FID_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define FID_LIMIT    450
#define FID_CRYO     VOID_CRYO      /* no cooling */

#define TCD_PROP_K   32             /* 5.12 Hz control        */
#define TCD_INTEG_K  34             /* last changed: 11/2/95  */
#define TCD_DERIV_K  59
#define TCD_CONTROL  SLOW_CONTROL
#define TCD_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define TCD_LIMIT    400
#define TCD_CRYO     VOID_CRYO      /* no cooling */

#define ECD_PROP_K   21             /* 5.12 Hz control        */
#define ECD_INTEG_K  18             /* last changed: 11/2/95  */
#define ECD_DERIV_K  50
#define ECD_CONTROL  SLOW_CONTROL
#define ECD_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define ECD_LIMIT    400
#define ECD_CRYO     VOID_CRYO      /* no cooling */

#define uECD_PROP_K   21             /* 5.12 Hz control        */
#define uECD_INTEG_K  16             /* last changed: 12/16/96 */
#define uECD_DERIV_K  54             /* same as FID PID const.s*/
#define uECD_CONTROL  SLOW_CONTROL
#define uECD_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define uECD_LIMIT    400
#define uECD_CRYO     VOID_CRYO      /* no cooling */

#define LDID_PROP_K   21             /* 5.12 Hz control       */
#define LDID_INTEG_K  16             /* Last changed: (FID copy) */
#define LDID_DERIV_K  54
#define LDID_CONTROL  SLOW_CONTROL   /* slow control rate */
#define LDID_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define LDID_LIMIT    400
#define LDID_CRYO     VOID_CRYO      /* no cooling */

#define NPD_PROP_K   21             /* last changed: 11/2/95  */
#define NPD_INTEG_K  21
#define NPD_DERIV_K  43
#define NPD_CONTROL  SLOW_CONTROL
#define NPD_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define NPD_LIMIT    400
#define NPD_CRYO     VOID_CRYO      /* no cooling */

#define FPD_PROP_K   14             /* last tuned: 10/15/96 on SN 127         */
#define FPD_INTEG_K  11             /*  w/ Pdiv-Ddiv=9,16,9 w/ final heaters  */
#define FPD_DERIV_K  33
#define FPD_CONTROL  FPD_BLOCK_CONTROL
#define FPD_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define FPD_LIMIT    250
#define FPD_CRYO     VOID_CRYO      /* no cooling */

/************************/
/* Inlet zone constants */
/************************/

#define PP_PROP_K    41             /* last changed: 11/2/95  */
#define PP_INTEG_K   36
#define PP_DERIV_K   92
#define PP_CONTROL   SLOW_CONTROL
#define PP_RATE      MAX_ZONE_RATE  /* max ramp rate */
#define PP_LIMIT     400
#define PP_CRYO      VOID_CRYO      /* no cryo used */

#define COC_PROP_K   27             /* Last tuned: 2/16/94 with fan full on */
#define COC_INTEG_K  34             /* and cryo blast fitting installed     */
#define COC_DERIV_K  43
#define COC_CONTROL  PCOC_CONTROL
#define COC_RATE     MAX_PCOC_RATE  /* max ramp rate */
#define COC_LIMIT    450
#define COC_CRYO     PCOC_CRYO      /* passive cryo used */

#define SS_PROP_K    54              /* last changed: 11/2/95  */
#define SS_INTEG_K   50
#define SS_DERIV_K   117
#define SS_CONTROL   SLOW_CONTROL
#define SS_RATE      MAX_ZONE_RATE  /* max ramp rate */
#define SS_LIMIT     400
#define SS_CRYO      VOID_CRYO      /* no cryo used */

#define PTV_PROP_K   0
#define PTV_INTEG_K  0
#define PTV_DERIV_K  0
#define PTV_CONTROL  PCOC_CONTROL
#define PTV_RATE     MAX_PCOC_RATE  /* max ramp rate */
#define PTV_LIMIT    450
#define PTV_CRYO     VOID_CRYO      /* no cryo used */

#define ACI_PROP_K   99
#define ACI_INTEG_K  86
#define ACI_DERIV_K  225
#define ACI_CONTROL  PCOC_CONTROL
#define ACI_RATE     MAX_ACI_RATE  /* max ramp rate */
#define ACI_LIMIT    450
#define ACI_CRYO     VOID_CRYO      /* no cryo used */

/* Sim Dis Inlet: new non-kludge version of ACI */
#define SMD_PROP_K   99
#define SMD_INTEG_K  86
#define SMD_DERIV_K  225
#define SMD_CONTROL  PCOC_CONTROL
#define SMD_RATE     MAX_ACI_RATE  /* max ramp rate */
#define SMD_LIMIT    450
#define SMD_CRYO     AIR_COOL       /* air cooling only */

/* CIS4 Inlet: Pilot version of PTV: tuned 7/26/96 */
#define CS4_PROP_K   51
#define CS4_INTEG_K  31
#define CS4_DERIV_K  18
#define CS4_CONTROL  CIS4_CONTROL
#define CS4_RATE     MAX_VERY_FAST_RATE  /* max ramp rate */
#define CS4_LIMIT    450
#define CS4_CRYO     CIS4_CRYO      /* CIS4 cryo cooling */

/* Volatiles inlet */
#define VI_PROP_K    23                  /* last changed:  8/2/96  */
#define VI_INTEG_K   21
#define VI_DERIV_K   49
#define VI_CONTROL   SLOW_CONTROL
#define VI_RATE      MAX_ZONE_RATE      /* max ramp rate */
#define VI_LIMIT     400
#define VI_CRYO      VOID_CRYO          /* no cryo used */

/* PCM inlet */
#define PCM_PROP_K    27             /* REVISIT: what should we put here? */
#define PCM_INTEG_K    9
#define PCM_DERIV_K   78
#define PCM_CONTROL   SLOW_CONTROL
#define PCM_RATE      MAX_ZONE_RATE  /* max ramp rate */
#define PCM_LIMIT     400
#define PCM_CRYO      VOID_CRYO      /* no cryo used */

/**********************/
/* Aux zone constants */
/**********************/

#define VLV_PROP_K   36              /* last changed: 11/2/95  */
#define VLV_INTEG_K  30
#define VLV_DERIV_K  86
#define VLV_CONTROL  SLOW_CONTROL
#define VLV_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define VLV_LIMIT    350
#define VLV_CRYO     VOID_CRYO      /* no cryo used */

#define MSD_PROP_K   40
#define MSD_INTEG_K  25
#define MSD_DERIV_K  125
#define MSD_CONTROL  SLOW_CONTROL
#define MSD_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define MSD_LIMIT    400
#define MSD_CRYO     VOID_CRYO      /* no cryo used */

#define AED_PROP_K   53
#define AED_INTEG_K  80
#define AED_DERIV_K  75
#define AED_CONTROL  SLOW_CONTROL
#define AED_RATE     MAX_ZONE_RATE  /* max ramp rate */
#define AED_LIMIT    400
#define AED_CRYO     VOID_CRYO      /* no cryo used */

/* Nickel catalyst values: lmf 8/29/95 */
#define UNK_PROP_K   12
#define UNK_INTEG_K  10
#define UNK_DERIV_K  30
#define UNK_CONTROL  SLOW_CONTROL
#define UNK_RATE     MAX_AUX_RATE  /* max ramp rate */
#define UNK_LIMIT    400
#define UNK_CRYO     VOID_CRYO      /* no cryo used */

/* Cryo trap: last tuned 11/4/96 at T=200 (Toven=50)        */
/*            quartz support Ku=113,Pu=24.15 PIDdiv=11,19,9 */

#define C_T_PROP_K   68
#define C_T_INTEG_K  56
#define C_T_DERIV_K  82
#define C_T_CONTROL  CRYO_TRAP_CONTROL
#define C_T_RATE     MAX_VERY_FAST_RATE
#define C_T_LIMIT    450
#define C_T_CRYO     TRAP_CRYO      /* cryo trap cryo used */

/* Nickel catalyst values: lmf 8/29/95 */
#define NIC_PROP_K   12
#define NIC_INTEG_K  10
#define NIC_DERIV_K  30
#define NIC_CONTROL  SLOW_CONTROL
#define NIC_RATE     MAX_AUX_RATE  /* max ramp rate */
#define NIC_LIMIT    400
#define NIC_CRYO     VOID_CRYO      /* no cryo used */

/* FPD transfer line auxiliary zone */
#define FXR_PROP_K   23          /* last tuned: on 10/15/96 unit SN 127 */
#define FXR_INTEG_K  17          /*  w/ Pdiv-Ddiv=9,16,9 & new heaters  */
#define FXR_DERIV_K  60
#define FXR_CONTROL  FPD_XFR_CONTROL
#define FXR_RATE     0          /* max ramp rate */
#define FXR_LIMIT    250
#define FXR_CRYO     VOID_CRYO      /* no cooling */

/**************************/
/* Oven control constants */
/**************************/

/* Last changed: 7/2/93 JSD */
/* these are the same oven constants used in 5890 Series II */
#define OVN_PROP_K   48  /*  2.67 deg     = full power */
#define OVN_INTEG_K  13  /* 12.31 deg*sec = full power */
#define OVN_DERIV_K  88  /*  2.32 deg/sec = full power */
#define OVN_CONTROL  OVEN_CONTROL
#define OVN_RATE     MAX_OVEN_RATE
#define OVN_LIMIT    450

#define FST_PROP_K   48
#define FST_INTEG_K  13
#define FST_DERIV_K  88
#define FST_CONTROL  OVEN_CONTROL
#define FST_RATE     MAX_FAST_RATE
#define FST_LIMIT    450

/* Cryo Control Constants */

#define OVN_P_N2  10     /* OVN_CRYO constants */
#define OVN_P_CO2 10

#define CIS_P_N2  40     /* CIS4_CRYO constants */
#define CIS_P_CO2 40

#define C_T_P_N2  20     /* TRAP_CRYO constants */
#define C_T_P_CO2 20

/*****************************/
/*   TYPEDEFS                */
/*****************************/

typedef enum
{
   VOID_CRYO      = 0,
   OVN_CRYO       = 1,
   PCOC_CRYO      = 2,
   CIS4_CRYO      = 3,
   C_T_CRYO       = 4,
   AIR_COOL       = 5,
   MAX_CRYO       = 6          /* marker for maximum possible cryo control */

} CRYO_CONTROL;

typedef struct
{
   BIT8         prop;
   BIT8         integ;
   BIT8         deriv;
   ZONE_CONTROL control_type;
   U_INT32      max_rate;
   U_INT16      max_setpt;
   RAMP_COMP    ramp_comp;
   INT8         min_control_error;
   INT8         max_control_error;
   TEMP_SENSOR  sensor_type;
   CRYO_CONTROL cryo_control_type;

} ZONE_INFO, *pZONE_INFO;

/* Pneumatics EEPROM module PID storage

   Here is the new RAM definition for storage of the eeprom pid stuff.
You should init the eeprom contents to zero in your program.  Zero is not
a valid entry for any of these parameters (see DTZT cmd).  Any parameters
in the eeprom that are zero will therefore be left unchanged (remain what
is stored in power-fail RAM).  I call a series of functions, one per parameter,
to transfer the uncompressed parameters into the working values.  For example:

   if ( F_Inlet_Zone_Eeprom_Info.prop_mult != 0 )
      (void) SetPropGain( F_Inlet_Zone_Eeprom_Info.prop_mult );

What will determine whether to update the working values is unclear to me.  I
would still like to have a "dirty" bit that is cleared after updating the
working values.

*/

/* Pneumatics EEPROM module PID storage */

typedef struct
{                                    /*  valid    valid    undef'ed  offset   */
                                     /*  minimum  maximum  value              */
                                     /*  -------  -------  --------  ------   */
   BIT8         prop_mult;           /*     1     255         0        0      */
   BIT8         integ_mult;          /*     1     255         0        0      */
   BIT8         deriv_mult;          /*     1     255         0        0      */
   BIT8         prop_div;            /*     8     24          0        0      */
   BIT8         integ_div;           /*     8     24          0        0      */
   BIT8         deriv_div;           /*     8     24          0        0      */
   INT16        control_freq;        /*     1     2           0      CFR_OFST */
   BIT8         cryo_control_type;   /*     1     6           0      CCT_OFST */
   BIT8         min_integ_power;     /*     1     4           0      INP_OFST */
   BIT8         max_integ_power;     /*     1     4           0      INP_OFST */
   INT8         min_control_error;   /*   -31     -1          0        0      */
   INT8         max_control_error;   /*     1     32          0        0      */
   BIT8         sensor_type;         /*     1     2           0      SNR_OFST */
   INT32        max_rate;            /*     0     2046     NO_MAXRATE  0      */
   INT16        min_setpt;           /*   -200    50       NO_MINSTPT  0      */
   U_INT16      max_setpt;           /*    25     500            0     0      */
   BIT8         ramp_comp;           /*     1     3           0      RMP_OFST */
   BIT8         therm_config_mod;    /* 1= new eeprom data available          */

} EEPROM_ZONE_INFO, *pEEPROM_ZONE_INFO;

typedef enum
{
   NO_COOLENT   =  0,   /* no coolent used                                 */
   OVEN_COOLENT =  1,   /* use the coolent type indicated by the oven cryo */
                        /* valve bits                                      */
   AIR_COOLENT  =  2,   /* forced air cooling used                         */
   GC_COOLENT   =  3    /* used the type of coolent determined by other    */
                        /* thermal systems using cryo (if any)             */

} CRYO_COOLENT;

typedef enum
{
   NO_CRYO    =  0, /* WARNING: this MUST be zero - it is part of a bit field */
   N2_CRYO    =  1, /*          used in the CW commands in hostcommand, sigh. */
   CO2_CRYO   =  2,
   FORCED_AIR =  3

} CRYO_TYPE;

typedef struct
{
   INT16        min_CO2_setpt;          /* minimum LCO2 setpt                 */
   INT16        min_N2_setpt;           /* minimum LN2 setpt                  */
   INT16        min_no_cryo_setpt;      /* minimum forced air setpt           */
   CRYO_COOLENT default_coolent;        /* default type of coolent fluid      */
   U_INT8       CO2_gain;               /* LCO2 control gain                  */
   U_INT8       N2_gain;                /* LN2 control gain                   */
   INT8         cryo_blast_on_error;    /* temp diff at which to turn cryo on */
   INT8         cryo_blast_off_error;   /* temp diff at which to turn cryo off*/
   BIT8         air_coolent_allowed;    /* flag: 0 = not allowed              */
   BIT8         N2_coolent_allowed;     /* flag: 0 = not allowed              */
   BIT8         CO2_coolent_allowed;    /* flag: 0 = not allowed              */
   U_INT8       target_demand;          /* target heater demand               */

} CRYO_INFO, *pCRYO_INFO;


typedef enum
{
   OVEN_ZONE  = 0,
   DETA_ZONE  = 1,
   DETB_ZONE  = 2,
   INJA_ZONE  = 3,
   INJB_ZONE  = 4,
   AUXA_ZONE  = 5,
   AUXB_ZONE  = 6,
   OVEN_CRYO  = 7,
   INJA_CRYO  = 8,
   INJB_CRYO  = 9,
   AUXA_CRYO  = 10,
   AUXB_CRYO  = 11,
   NULL_ZONE  = 12,       /* no zone association     */
   UND_ZONE   = 13        /* undefined zone location */

} ZONE_TYPE;

typedef struct
{
   AUX_TYPE type;
   AUX_TYPE old_type;

} AUX_ZONE_CONFIG;

typedef enum
{
  LT_70_WATTS  = 0,
  LT_150_WATTS = 1,
  GT_150_WATTS = 2,
  NO_HEATER    = 3,
  OVER_CURRENT = 4

} WATTAGE;

typedef struct
{
   BIT8      zones_installed;        /* bit field indicating presence     */
   BIT8      cryo_valve_conflict;    /* bit field indicating cryo valve   */
                                     /* conflict with a manual ss inlet   */
   BIT8      zones_over_wattage;     /* bit field indicating over wattage */
   INT32     oven_calib;             /* one-pt oven calibration constant  */
   DATETIME  oven_calib_date;        /* date of oven calibration          */
   U_INT16   max_thermal_wattage;    /* maximum total small zone and oven */
                                     /* power consumption                 */

} OVEN_ZONE_CONFIG;

typedef struct
{
  TEMP_SENSOR   sensor_type;            /* type of temperature sensor         */
  U_INT16       zone_limit;             /* max temp setpt in degrees C        */
  U_INT32       zone_min_actual;        /* min temp actual in 64*256ths deg C */
  INT16         zone_min_setpt;         /* min temp setpt in degrees C        */
  U_INT32       max_rate;               /* max ramp rate in degrees C/min     */
  RAMP_COMP     ramp_comp;              /* type of ramp compensation          */
  BIT8          zone_type;              /* indicates type of zone installed   */
  U_INT32       zone_max;               /* user settable max temp             */
  U_INT32       zone_rdy_delay;         /* delay time for readiness           */

/* zone tuning parameters */
  U_INT8        zone_prop_mult;         /* multiplier for proportional gain   */
  U_INT8        zone_integ_mult;        /* multiplier for integral     gain   */
  U_INT8        zone_deriv_mult;        /* multiplier for derivative   gain   */
  U_INT8        zone_prop_divisor;      /* shift divisor for proportional gain*/
  U_INT8        zone_integ_divisor;     /* shift divisor for integral  gain   */
  U_INT8        zone_deriv_divisor;     /* shift divisor for derivative gain  */
  U_INT8        old_prop_mult;          /* multiplier for proportional gain   */
  U_INT8        old_integ_mult;         /* multiplier for integral     gain   */
  U_INT8        old_deriv_mult;         /* multiplier for derivative   gain   */
  U_INT8        old_prop_divisor;       /* shift divisor for proportional gain*/
  U_INT8        old_integ_divisor;      /* shift divisor for integral  gain   */
  U_INT8        old_deriv_divisor;      /* shift divisor for derivative gain  */
  BIT8          zone_user_config;       /* flags: user config params entered  */
  DATETIME      tune_datetime;          /* date of last tuning                */
  ON_OFF        zone_tune_on_off;       /* enable zone tuning                 */
  INT32         zone_tune_prop_gain;    /* prop gain in units of 1/100ths deg */
                                        /*  for full power                    */
  INT32         zone_tune_time_period;  /* tuning oscilliation time period    */
  INT16         zone_control_freq;      /* control freq in 1/100th's of a sec */
  INT32         min_integ_accum;        /* minimum integral accumulator value */
  INT32         max_integ_accum;        /* maximum integral accumulator value */
  INTEG_CLAMP   min_I_accum_percent_FP; /* min integral accum percent full pwr*/
  INTEG_CLAMP   max_I_accum_percent_FP; /* max integral accum percent full pwr*/
  INT8          min_control_error;      /* neg temp error to start PID control*/
  INT8          max_control_error;      /* pos temp error to start PID control*/
  INT32         min_PID_error;          /*  neg error to start PID control   */
  INT32         max_PID_error;          /*  pos error to start PID control   */
  U_INT16       dead_time;              /* 4 second dead time in milliseconds */
  U_INT16       dead_time2;             /* dead time in 1000ths of a minute   */
  U_INT16       brake_time;             /* anticipatory time before a ramp    */
                                        /* ends in 1000ths of a minute        */
  INT32         ramp_mult;              /*multiplier for rate to demand offset*/
  INT32         ramp_div;               /* divisor for rate to demand offset  */

  U_INT32       setpt_filt_mask;        /* mask used to filter the zone setpt */
  U_INT8        setpt_filt_shift;       /* mask used to filter the zone setpt */
  ZONE_CONTROL  zone_control_type;      /* type of pid control                */
  CRYO_CONTROL  cryo_control_type;      /* type of cooling control used       */
  ZONE_TYPE     zone_location;          /* location of zone, e.g. front inlet */
  BIT8          sensor_present;         /* true/false for sensor found        */
  BIT8          pwr_on_sensor_present;  /* last pwr on true/false for sensor  */                                        /* present - used by PCM              */
  WATTAGE       wattage;                /* wattage range:  NOTE: only used    */
                                        /* for small zones                    */

   BIT8         cryo_installed;         /* boolean var. indicating presence   */
   BIT8         *pvalve_image;          /* pointer do the cryo valve drive
                                           register image */
   BIT8         valve_bit;              /* bit mask indicating (logic 1) the bit
                                           in the valve image */
   CRYO_TYPE    cryo_type;              /* type of cryo installed             */
   U_INT8       cryo_gain;              /* gain for cryo control              */
   U_INT8       cryo_target;            /* target demand for oven for cryo    */
   U_INT16      bang_period;            /* # of line freq interrupts in one   */
                                        /*  bang-bang control cryo burst      */
   U_INT16      cryo_period;            /* # of line freq interrupts in one   */
                                        /*  cryo period                       */
   U_INT32      cryo_limit;             /* maximum cryo accumulator value     */
                                        /*  - dependent upon the cryo period  */
   U_INT32      cryo_max_on_limit;      /* maximum cryo accumulator value     */
                                        /*  when duty cycle limitted.         */
   U_INT16      max_cryo_on_count;      /* max # of line freq interrupts for  */
                                        /*  which the cryo valve can be open  */
   INT32        cryo_blast_on_error;    /* temp diff at which to turn cryo on */
   INT32        cryo_blast_off_error;   /* temp diff at which to turn cryo off*/
   U_INT16      cryo_blast_time;        /* time to dwell in cryo blast @ setpt*/
} ZONE_CONFIG;

/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/

extern  const CRYO_INFO CRYO_TABLE[];
extern        CRYO_TYPE Cryo_Type;
extern        BIT8      Single_Cryo;      /* boolean: TRUE:  no oven cryo & one
                                                             small zone cryo
                                                      FALSE: otherwise          */
extern        ZONE_TYPE Single_Cryo_Type; /* zone location for single small zone
                                             with cryo and no oven cryo, NULL
                                             _ZONE otherwise                    */

#pragma SECTION DATA=pfail

extern  OVEN_ZONE_CONFIG Zone_Config;
extern  ZONE_CONFIG      Oven_Zone_Config;
extern  ZONE_CONFIG      Deta_Zone_Config;
extern  ZONE_CONFIG      Detb_Zone_Config;
extern  ZONE_CONFIG      Inja_Zone_Config;
extern  ZONE_CONFIG      Injb_Zone_Config;
extern  ZONE_CONFIG      Auxa_Zone_Config;
extern  ZONE_CONFIG      Auxb_Zone_Config;
extern  EEPROM_ZONE_INFO F_Inlet_Zone_Eeprom_Info;
extern  EEPROM_ZONE_INFO B_Inlet_Zone_Eeprom_Info;
extern  EEPROM_ZONE_INFO F_Det_Zone_Eeprom_Info;
extern  EEPROM_ZONE_INFO B_Det_Zone_Eeprom_Info;

#pragma SECTION UNDO

#endif
